<?php
!defined('P_W') && exit('Forbidden');
$pw_pricedb = House::loadDB('pricedetail');
InitGP(array('hid','subaction'),'GP');
!$hid && adminmsg('operate_error');
$baseurl = $basename . "&action=pricedetail&hid=$hid";
include D_P.'data/bbscache/house_config.php';
if (empty($subaction) || $subaction == 'search') {
	InitGP(array('page'),'GP',2);
	$pw_pricedb->setBasename($baseurl);
	$pricedetails = $pw_pricedb->queryPricedetailByHid($hid,$page);
} elseif ($subaction == 'del') {
	InitGP(array('ids'),'GP',2);
	empty($ids) && adminmsg("请选择要删除的价格明细",$baseurl);
	$pw_pricedb->deletePricedetail($ids);
	$pageCache = getPageCache('info',$hid);
	$pageCache->deleteCache('newPrice');
	Showmsg('operate_success',$baseurl);
} elseif ($subaction == 'edit') {
	define('AJAX',1);
	$posthash = EncodeUrl("$baseurl&subaction=edit&", true);
	InitGP(array('id','step'),'GP',2);
	if (empty($step)) {
		$price = $pw_pricedb->queryPricedetailById($id);
	}elseif($step == '2'){
		InitGP(array('title','property','buildtype','paystatus','currentprice','opentime','paytime','hnum'),'GP',1);
		empty($title) && adminmsg('标题不能为空',$baseurl);
		$opentime = PwStrtoTime($opentime);
		$paytime = PwStrtoTime($paytime);
		$price = array(
			'id' 			=> $id,
			'hid'			=> $hid,
			'title'			=> $title,
			'propertyid'	=> $property,
			'buildtypeid'	=> $buildtype,
			'paystatusid'	=> $paystatus,
			'currentprice'	=> (int)$currentprice,
			'opentime'		=> $opentime,
			'paytime'		=> $paytime,
			'hnum'			=> (int)$hnum,
		);
		$pw_pricedb->replacePricedetail($price,$hid);
		$pageCache = getPageCache('info',$hid);
		$pageCache->deleteCache('newPrice');
		Showmsg('ajaxma_success',$baseurl);
	}
	include PrintMode('info');ajax_footer();exit;
}
include PrintMode('info');
exit;
?>